package lion.dev.matcher;

import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;

/**
 * 正则匹配
 * 
 * @author lion
 * @email hl_0074@sina.com
 * @date 2014年5月8日
 */
public class RegexMatcher implements Matcher {

	private Pattern pattern;
	private String name;

	public RegexMatcher(String pattern) {

		this.name = pattern;
		this.pattern = Pattern.compile(pattern);
	}

	@Override
	public boolean match(String name) {

		if (StringUtils.isBlank(name)) { return false; }

		return this.pattern.matcher(name).matches();
	}

	@Override
	public boolean equals(String name) {

		return StringUtils.equals(this.name, name);
	}

}
